package com.zhu.storesmanager.network;

import com.zhu.storesmanager.models.SyncModel;
import com.zhu.storesmanager.utils.Log;

public class ParseNetworkData {

	/**
	 * 解析登录结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.LoginResult parseLoginResult(Object result){
		Log.e("parseLoginResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.LoginResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析安全结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.SecureResult parseSecureResult(Object result){
		Log.e("parseSecureResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.SecureResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析开始同步结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.StartResult parseStartSyncResult(Object result){
		Log.e("parseStartSyncResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.StartResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析型号结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.ProductResult parseModelsResult(Object result){
		Log.e("parseModelsResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.ProductResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析签入信息结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.ResultStatus parsePromoterCheckResult(Object result){
		Log.e("parsePromoterCheckResult=" + result);
		return parseResultStatus(result);
	}

	/**
	 * 解析销量上报信息结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.PromoterSalesResult parsePromoterSalesResult(Object result){
		Log.e("parsePromoterSalesResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.PromoterSalesResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析同步完成结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.ResultStatus parseFinishSyncResult(Object result){
		Log.e("parseFinishSyncResult=" + result);
		return parseResultStatus(result);
	}

	/**
     * 解析请求网络时间数据
     * @param result 网络数据
     */
    public static SyncModel.TimeResult parseNetworkTimeResult(Object result){
        Log.e("parseNetworkTimeResult=" + result);
        if(result != null){
            try {
                return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.TimeResult.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }


    /**
     * 解析同步完成结果数据
     * @param result 网络数据
     */
    public static SyncModel.ResultStatus parseResultStatus(Object result){
    	Log.e("parseResultStatus=" + result);
        if(result != null){
            try {
                return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.ResultStatus.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    /**
     * 解析数据词典结果数据
     * @param result 网络数据
     */
    public static SyncModel.DictResult parseDictsResult(Object result){
        Log.e("parseDictsResult=" + result);
        if(result != null){
            try {
                return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.DictResult.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    /**
     * 解析拜访项目标签结果数据
     * @param result 网络数据
     */
    public static SyncModel.ProjectResult parseProjectResult(Object result){
        Log.e("parseProjectResult=" + result);
        if(result != null){
            try {
                return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.ProjectResult.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    /**
     * 解析提醒结果数据
     * @param result 网络数据
     */
    public static SyncModel.ReminderResult parseRemindResult(Object result){
        Log.e("parseRemindResult=" + result);
        if(result != null){
            try {
                return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.ReminderResult.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    /**
     * 解析拜访任务数据
     * @param result 网络数据
     */
    public static SyncModel.VisitResult parseVisitResult(Object result){
        Log.e("parseVisitResult=" + result);
        if(result != null){
            try {
                return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.VisitResult.class);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    /**
	 * 解析区域结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.QueryRegionResult parseRegionResult(Object result){
		Log.e("parseRegionResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.QueryRegionResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析城市结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.QueryCityResult parseCityResult(Object result){
		Log.e("parseCityResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.QueryCityResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析门店结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.QueryCounterResult parseCounterResult(Object result){
		Log.e("parseCounterResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.QueryCounterResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析门店拜访历史记录结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.QueryVisitResult parseVisitListResult(Object result){
		Log.e("parseVisitListResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.QueryVisitResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	/**
	 * 解析门店拜访内容结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.QueryVisitContentResult parseVisitContentResult(Object result){
		Log.e("parseVisitContentResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.QueryVisitContentResult.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}


	/**
	 * 解析销量历史记录结果数据
	 * @param result 网络数据
	 */
	public static SyncModel.DesDataVisitContentSales parseSalesListResult(Object result){
		Log.e("parseSalesListResult=" + result);
		if(result != null){
			try {
				return HttpUtil.getObjectMapper().readValue((String)result, SyncModel.DesDataVisitContentSales.class);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}
